
package org.apache.mina.common;

/**
 * Represents the type of idleness of {@link IoSession} or {@link IoSession}.
 * There are three types of idleness:
 * <ul>
 * <li>{@link #READER_IDLE} - No data is coming from the remote peer.</li>
 * <li>{@link #WRITER_IDLE} - Session is not writing any data.</li>
 * <li>{@link #BOTH_IDLE} - Both {@link #READER_IDLE} and {@link #WRITER_IDLE}.</li>
 * </ul>
 * <p>
 * 
 * 封装IoSession的空闲状态（新的JDK版本中，应为一枚举），有三种状态：
 * READER_IDLE，远程设备无数据；WRITER_IDLE，会话不写任何数据；BOTH_IDLE，即不读数据也不写数据。
 * 
 * Idle time settings are all disabled by default. You can enable them using
 * {@link IoSession#setIdleTime(IdleStatus,int)}.
 * 
 * 空闲时间默认是不能设置的，你可以通过IoSession.setIdleTime(IdleStatus,int)方法来设置。
 */
public class IdleStatus {
    /**
     * Represents the session status that no data is coming from the remote
     * peer.
     * 
     * 代表远程设备无数据，即读空闲状态。
     */
    public static final IdleStatus READER_IDLE = new IdleStatus("reader idle");

    /**
     * Represents the session status that the session is not writing any data.
     * 
     * 代表会话不在写任何数据，即写空闲状态
     */
    public static final IdleStatus WRITER_IDLE = new IdleStatus("writer idle");

    /**
     * Represents both {@link #READER_IDLE} and {@link #WRITER_IDLE}.
     * 
     * 代表读空闲和写空闲状态。
     */
    public static final IdleStatus BOTH_IDLE   = new IdleStatus("both idle");

    private final String           strValue;

    /**
     * Creates a new instance.
     * 
     * 创建一个新的实例。
     */
    private IdleStatus(String strValue) {
        this.strValue = strValue;
    }

    /**
     * Returns the string representation of this status.
     * <ul>
     * <li>{@link #READER_IDLE} - <tt>"reader idle"</tt></li>
     * <li>{@link #WRITER_IDLE} - <tt>"writer idle"</tt></li>
     * <li>{@link #BOTH_IDLE} - <tt>"both idle"</tt></li>
     * </ul>
     * 
     * 返回状态所对应的字符串
     */
    public String toString() {
        return strValue;
    }
}